/**
 * Project Name:fire-industry-DM-center
 * File Name:GeoPoint.java
 * Package Name:com.firestone.bean.entity.elasticsearch.nested
 * Date:2018年4月11日上午11:09:53
 *
*/

package com.firestone.bean.entity.elasticsearch.nested;

import org.springframework.data.geo.Point;

/**
 * @Description: TODO(经纬度地址)
 * @author CAIYJ
 * @date 2018年4月11日 上午11:09:53
 */
public class GeoPoint {
    private double lat;
    private double lon;

    @SuppressWarnings("unused")
    private GeoPoint() {
        // required by mapper to instantiate object
    }

    public GeoPoint(double latitude, double longitude) {
        this.lat = latitude;
        this.lon = longitude;
    }

    public double getLat() {
        return lat;
    }

    public double getLon() {
        return lon;
    }

    /**
     * build a GeoPoint from a {@link org.springframework.data.geo.Point}
     *
     * @param point
     *            {@link org.springframework.data.geo.Point}
     * @return a
     *         {@link org.springframework.data.elasticsearch.core.geo.GeoPoint}
     */
    public static GeoPoint fromPoint(Point point) {
        return new GeoPoint(point.getX(), point.getY());
    }

    public static Point toPoint(GeoPoint point) {
        return new Point(point.getLat(), point.getLon());
    }
}
